using System;
using Headsight.BPMN2WF.BPMN.Schemas;
using Headsight.BPMN2WF.Testing.TestObjCtors;
using Headsight.BPMN2WF.Transformation.Transformers;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Headsight.BPMN2WF.Transformation.BPMN2TransformerMappings
{
    [TestClass]
    public class BPMN2WFTransformationsSimpleTest
    {
        private IBPMN2WFTransformations _sut;

        [TestInitialize]
        public void SetUp()
        {
            _sut = new BPMN2WFTransformationsSimple();
        }

        [TestMethod]
        public void Get_tUserTask()
        {
            PerformTest(typeof(tUserTask), typeof(BPMN2WFTransformationCustomWFUserTask));
        }

        [TestMethod]
        public void Get_tEndEvent()
        {
            PerformTest(typeof(tEndEvent), typeof(BPMN2WFTransformationTerminateEndEvent));
        }

        [TestMethod]
        public void Get_Default()
        {
        //    PerformTest(typeof(tGateway), typeof(BPMN2WFTransformation_WriteLine));
        //    PerformTest(typeof(tParallelGateway), typeof(BPMN2WFTransformation_WriteLine));
       //     PerformTest(typeof(tInclusiveGateway), typeof(BPMN2WFTransformation_WriteLine));
      //      PerformTest(typeof(tExclusiveGateway), typeof(BPMN2WFTransformation_WriteLine));
      //      PerformTest(typeof(tEventBasedGateway), typeof(BPMN2WFTransformation_WriteLine));
    //        PerformTest(typeof(tComplexGateway), typeof(BPMN2WFTransformation_WriteLine));
        //    PerformTest(typeof(tChoreographyActivity), typeof(WFActivityFromBPMNBuilder_WriteLine));
            PerformTest(typeof(tSubChoreography), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tChoreographyTask), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tCallChoreography), typeof(BPMN2WFTransformationWriteLine));
     //       PerformTest(typeof(tEvent), typeof(WFActivityFromBPMNBuilder_WriteLine));
     //       PerformTest(typeof(tThrowEvent), typeof(WFActivityFromBPMNBuilder_WriteLine));
            PerformTest(typeof(tIntermediateThrowEvent), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tImplicitThrowEvent), typeof(BPMN2WFTransformationWriteLine));
            //PerformTest(typeof(tEndEvent), typeof(WFActivityFromBPMNBuilder_WriteLine));
     //       PerformTest(typeof(tCatchEvent), typeof(WFActivityFromBPMNBuilder_WriteLine));
            PerformTest(typeof(tStartEvent), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tIntermediateCatchEvent), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tBoundaryEvent), typeof(BPMN2WFTransformationWriteLine));
       //     PerformTest(typeof(tActivity), typeof(WFActivityFromBPMNBuilder_WriteLine));
            PerformTest(typeof(tTask), typeof(BPMN2WFTransformationWriteLine));
            //PerformTest(typeof(tUserTask), typeof(WFActivityFromBPMNBuilder_WriteLine));
            PerformTest(typeof(tServiceTask), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tSendTask), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tScriptTask), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tReceiveTask), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tManualTask), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tBusinessRuleTask), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tSubProcess), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tTransaction), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tAdHocSubProcess), typeof(BPMN2WFTransformationWriteLine));
            PerformTest(typeof(tCallActivity), typeof(BPMN2WFTransformationWriteLine));
        }

        private void PerformTest(Type p0, Type p1)
        {
            var tFlowElement = (tFlowElement)Activator.CreateInstance(p0);

            var bpmnFlowNode = new BPMNFlowNodeCtor().WithTFlowElement(tFlowElement).Create();

            var result = _sut.Get(bpmnFlowNode);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, p1);
        }
    }
}